<?php

/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Gmap
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
class Gmap_View_Helper_Gmap extends Zend_View_Helper_Abstract
{

	/*
	 * @param Radcodes_Lib_Google_Map $google_map
	 */
	public function gmap(Radcodes_Lib_Google_Map $google_map, $options=array())
	{
		if (isset($options['width']))
		{
			$google_map->setWidth($options['width']);
		}
		if (isset($options['height']))
		{
			$google_map->setHeight($options['height']);
		}
		if (isset($options['center']))
		{
			$google_map->setCenter($options['center']['lat'], $options['center']['lng']);
		}
		else
		{
			$google_map->centerOnMarkers();
		}
    
		if (isset($options['zoom']))
		{
			$google_map->setZoom($options['zoom']);
		}
		else
		{
			$zoom_margin = isset($options['zoom_margin']) ? $options['zoom_margin'] : 0.2;
			$google_map->zoomOnMarkers($zoom_margin);
		}
		
		$this->view->headScript()->appendFile($google_map->getGoogleJsUrl());
    
		$return = $google_map->getContainer()
		        . $google_map->getJavascriptHtmlSource();

    return $return;
	}
	

}